<template>
  <div class="subpage">
    <div class="tou">
      <i class="iconfont icon-shouye" @click="$router.push('/category')"></i>
      <h2 class="list_title">网易严选</h2>
      <i class="iconfont icon-gouwuche"></i>
      <i class="iconfont icon-sousuo"></i>
    </div>
    <ul class="navigation_bar">
      <router-link
        class="navigation_bar_li"
        v-for="item in navigationBar"
        :key="item.id"
        :to="`/category/${$route.params.id}/${item.id}`"
      >
        {{ item.name }}
      </router-link>
    </ul>
    <div class="product_list">
      <h2 class="product_list_title">{{ title_name }}</h2>
      <div class="fudon">
        <router-link
          class="product_list_data"
          v-for="item in productList"
          :key="item.id"
          :to="`/detail/${item.id}`"
        >
          <p class="product_list_data_img">
            <img :src="item.listPicUrl" alt="" />
          </p>
          <p class="product_list_data_title">
            <span class="xinpin">
              <img
                src="	https://yanxuan.nosdn.127.net/static-union/1669863110ec230b.png"
                alt=""
              />
            </span>
            <span class="title_img">
              <img
                src="https://yanxuan.nosdn.127.net/static-union/16698631101bcf18.png"
                alt=""
              />
            </span>
            <span class="title_jieshao">{{ item.name }}</span>
          </p>
          <p class="price">
            <span class="current_price"
              >￥<span class="aaa">{{ item.retailPrice }}</span></span
            >
            <span class="original_price"
              ><s>￥{{ item.sortOriginPrice }}</s></span
            >
          </p>
          <div v-if="item.finalPriceInfoVO.banner">
            <p class="youhui" v-if="item.finalPriceInfoVO.banner.title">
              <span class="xianshi">{{
                item.finalPriceInfoVO.banner.title
              }}</span>
              <span class="qianggou">{{
                item.finalPriceInfoVO.banner.content
              }}</span>
            </p>
            <p v-else>
              <span class="youhui_1">{{
                item.finalPriceInfoVO.banner.content
              }}</span>
            </p>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      navigationBar: [],
      productList: [],
      title_name: "",
    };
  },
  watch: {
    $route() {
      this.commodity();
    },
  },
  methods: {
    commodity() {
      axios
        .get(
          `/item/list.json?__timestamp=1682951925424&categoryId=${this.$route.params.id}&subCategoryId=${this.$route.params.subCategoryId}&categoryType=0`
        )

        .then((response) => {
          // 分类列表数据
          this.navigationBar = response.data.data.categoryL2List;
          this.productList = response.data.data.categoryItems.itemList;
          this.title_name = response.data.data.categoryItems.category.frontName;
          // console.log("888888", response.data.data.categoryItems.itemList);
          // console.log("66666", response.data.data.categoryL2List);
          // console.log("----->", this.navigationBar[0].name);
        });
    },
  },
  mounted() {
    this.commodity();
  },
};
</script>

<style scoped>
.subpage {
  background-color: #eee;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
}
.tou {
  width: 100%;
  height: 44px;
  position: fixed;
  top: 0;
  left: 0;
  border-bottom: 1px solid #eee;
  padding-left: 10px;
  padding-right: 8px;
  box-sizing: border-box;
  margin: 0 auto;
  background-color: #fff;
  z-index: 50;
}
.icon-shouye {
  float: left;
  line-height: 44px;
  color: #666;
  font-size: 28px;
}
.list_title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 500;
}
.icon-sousuo,
.icon-gouwuche {
  float: right;
  font-size: 28px;
  line-height: 44px;
  margin-left: 10px;
  color: #666;
}
.navigation_bar {
  width: 100%;
  top: 45px;
  left: 0;
  position: fixed;
  display: flex;
  background-color: #fff;
  height: 30px;
  overflow: auto;
  padding: 0 15px;
  box-sizing: border-box;
  z-index: 100;
}
.navigation_bar .navigation_bar_li {
  height: 100%;
  line-height: 30px;
  text-align: center;
  padding: 0 8px;
  box-sizing: border-box;
  flex-shrink: 0;
  margin: 0 auto;
  color: #333;
  font-size: 14px;
  /* margin-right: 20px; */
}
.navigation_bar .router-link-active {
  color: red;
  border-bottom: 1px solid red;
}
.product_list {
  position: absolute;
  background-color: #fff;
  margin-top: 85px;
  overflow: auto;
  /* height: 100%; */
  width: 100%;
}

.product_list_title {
  height: 55px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #333;
}
.fudon {
  display: flex;
  flex-wrap: wrap;
}
.product_list_data {
  padding: 0 5px 26px 10px;
  width: 172px;
}
.product_list_data_img {
  width: 172px;
  height: 172px;
}
.product_list_data_img img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.product_list_data_title {
  margin-top: 6px;
  color: #12161c;
  font-size: 14px;
  line-height: 16px;
  /* display: flex; */
}
.product_list_data_title .xinpin img {
  float: left;
  width: 23px;
  height: 15px;
  margin-right: 5px;
}
.product_list_data_title .title_img img {
  width: 15px;
  height: 15px;
  float: left;
  margin-right: 5px;
}
.current_price {
  color: #fa1e32;
  font-size: 12px;
}
.aaa {
  font-size: 22px;
}
.original_price {
  color: #999;
  font-size: 12px;
}
.youhui {
  width: 100%;
  height: 24px;
  background-color: #ffe9eb;
  border-radius: 12px;
}
.xianshi,
.youhui_1 {
  background-color: red;
  color: #fff;
  height: 24px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 24px;
  padding: 2px 8px;
  font-weight: 800;
}
.qianggou {
  color: #fa1e32;
  font-size: 10px;
  margin-left: 5px;
  font-weight: 800;
}
</style>
